//一和零  力扣474
//01背包 二维背包容量
class Solution {
public:
	int findMaxForm(vector<string>& strs, int m, int n) {
		vector<vector<int>> dp(m+1,vector<int>(n+1));
		//初始化
		int zero = 0;
		int one = 0;
		for(int i = 0; i < strs[0].size(); i++)
		{
			if(strs[0][i] == '0') zero++;
			else one++;
		}
		for(int i = 0; i <= m; i++)
		{
			for(int j = 0; j <= n; j++)
			{
				if(i >= zero && j >= one) dp[i][j] = 1;
			}
		}
		
		for(int i = 1; i < strs.size(); i++)
		{
			int x = 0;
			int y = 0;
			for(int j = 0; j < strs[i].size(); j++)
			{
				if(strs[i][j] == '0') x++;
				else y++;
			}
			for(int _i = m ; _i >=x; _i--)
			{
				for(int _j = n ; _j >=y; _j--)
				{
					dp[_i][_j] = max(dp[_i][_j],dp[_i-x][_j-y] + 1);
				}
			}
			
		}
		return dp[m][n];
		
	}
	
	
};
